package com.cat.dataStructure02;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/increasing-triplet-subsequence/description/
 * @create 2025/10/20 12:37
 * @since JDK17
 */

public class Solution28 {
    public boolean increasingTriplet(int[] nums) {
        int n = nums.length, top = 0;
        int[] max = new int[n], min = new int[n];
        min[0] = nums[0];
        max[n - 1] = nums[n - 1];
        for (int i = 1; i < n; i++) {
            min[i] = Math.min(min[i - 1], nums[i]);
        }
        for (int i = n - 2; i > 0; i--) {
            max[i] = Math.max(max[i + 1], nums[i]);
        }
        for (int i = 1; i < n - 1; i++) {
            if (nums[i] > min[i - 1] && nums[i] < max[i + 1]) {
                return true;
            }
        }

        return false;
    }
}
